package org.budo.xml;

import java.io.File;

import org.budo.support.lang.util.IoUtil;
import org.w3c.dom.Document;

/**
 * 对应一个Xml文件
 * 
 * @author lmw
 */
public class XmlFileObject extends AbstractXmlObject implements XmlObject {
    private Document document;

    private File file;

    public XmlFileObject(File file) {
        this.file = file;
        this.document = Xml.build(IoUtil.toInputStream(file));
    }

    public Document getDocument() {
        return this.document;
    }

    public File getFile() {
        return this.file;
    }

    @Override
    public XmlObject getChildNodeByName(String nodeName) {
        return this.getChildNodeByName(this.getDocument(), nodeName);
    }

    @Override
    public XmlObject[] getChildNodeArrayByName(String nodeName) {
        return this.getChildNodeArrayByName(this.getDocument(), nodeName);
    }
}